<template>
  <view></view>
</template>

<script>
import { fetch } from '../../utils/fetch'
export default {
  data() {
    return {}
  },
  //
  onLoad() {
    // this.getList()
    this.getAccessToken()
  },
  created() {},
  mounted() {},
  onReady() {},
  methods: {
    async getAccessToken() {
      const res = await fetch({
        url: 'http://localhost:3000/api/getAccessToken'
      })
      console.log('res:access', res.data.data.access_token)
      const access_token = res.data?.data?.access_token
      if (access_token) {
        uni.setStorageSync('access_token', access_token)
      } else {
        uni.showToast({ title: '获取access_token失败' })
      }
    },
    async getList() {
      try {
        const data = await fetch({
          url: 'http://localhost:3000/api/demo-json',
          data: {
            page: 1,
            size: 2
          }
        })
        console.log('data:', data)
      } catch (error) {
        console.log('error:', error)
      }

      // wx.request({
      //   url: 'http://localhost:3000/api/demo-json?page=1&size=2',
      //   method: 'GET',
      //   success: (res) => {
      //     console.log(res)
      //   },
      //   fail: (error) => {
      //     console.log('error', error)
      //   },
      // })
    }
  }
}
</script>

<style lang="scss"></style>
